package com.csu.tingtian.controller;

import com.csu.tingtian.common.CommonResponse;
import com.csu.tingtian.service.FarmRentCommentService;
import com.csu.tingtian.vo.FarmRentComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/farmrentcomment/")
public class FarmRentCommentController {
    @Autowired
    private FarmRentCommentService farmRentCommentService;
    //    用户对在某农场某次租赁发送评论
    @PostMapping("farmrentcomments/farmrentcomment")
    CommonResponse<FarmRentComment> userSendCommentToProduce(@RequestBody FarmRentComment farmRentComment){
        return farmRentCommentService.userSendCommentToProduce(farmRentComment);
    }
    //    用户删除对某农场的某条评论
    @DeleteMapping("farmname/{farmname}/username/{username}/time/{time}")
    CommonResponse<FarmRentComment> userDeleteComment(@PathVariable("farmname")String farmName,@PathVariable("username") String userName,@PathVariable("time")String time){
        return farmRentCommentService.userDeleteComment(farmName,userName,time);
    }
    //    用户查看某农场的评论
    @GetMapping("{farmname}/farmrentcomments")
    CommonResponse<List<FarmRentComment>> userGetCommentByFarmName(@PathVariable("farmname") String farmName){
        return farmRentCommentService.userGetCommentByFarmName(farmName);
    }
    //    给管理员返回租赁星级平均分为2分及其以下的farmName
    @GetMapping("farmname")
    CommonResponse<List<String>> returnFarmNameStarIsTwoOrLower(){
        return farmRentCommentService.returnFarmNameStarIsTwoOrLower();
    }
}
